import axios from "axios";
import type {AxiosResponse} from "axios";

const service = axios.create({
    baseURL:import.meta.env.VITE_APP_BASE_URL,
    timeout:60000
});


// 请求拦截器
// service.interceptors.request.use((config:InternalAxiosRequestConfig)=>{
service.interceptors.request.use((config)=>{

    // 携带token
    const token = localStorage.getItem("token");
    if(token){
        config.headers.token = token;
    }

    return config;
})


// 响应拦截器
service.interceptors.response.use((res:AxiosResponse)=>{




    return res;
},(err)=>{
    if(err.response.status===404){
        console.log("没有找到");
    }
})

export default service;